/* $Header: gc_tbls.c,v 2.2 01/10/02 10:29:18 przybyls Exp $ */

/* gc_tbls.c - workfile get/set for general GC commands */
/* Bob Cook; Oct 1993 */
/* Copyright (c) 1993, Hewlett-Packard Co. */


#include <typedefs.h>
#include <error.h>
#include <stddef.h>
#include <p_wkfile.h>
#include <p_status.h>
#include <wkfile.h>
#include <ramps.h>
#include <exception.h>
#include <err_handler.h>
#include <zone_config.h>
#include <zone_status.h>
#include <status.h>
#include <zone_ui.h>
#include <run_ui.h>
#include <sequence.h>
#include <seq_ui.h>
#include <clock_ui.h>
#include <method.h>
#include <p_ui.h>
#include <sig_types.h>
#include <valve_ui.h>
#include <als_ui.h>
#include <det_ui.h>


#define METH_NUM    METH_INT0
#define METH_TEMP   METH_INT0
#define METH_TIME   METH_INT2
#define METH_PRES   METH_INT0
#define METH_FLOW   METH_INT0

#define  FUEL_GAS  1
#define  UTIL_GAS  2
#define  MUG_GAS   3



/* definitions used with DummyFunction */
typedef UI_ERR (* const SET)(void *status, INT32 setpt, U_INT8 unused_parm);
typedef INT32  (* const GET)(void *status, U_INT8 unused_parm);


/********************* wrapper function prototypes *********************/
/*
 * Format:
 *    Get commands:
 *        mGetWrapperCommand(void *parameter, U_INT8 number)
 *    Set commands:
 *        mSetWrapperCommand(void *parameter, INT32 setpoint, U_INT8 number)
 *    Examples:
 *       parameter - pointer to oven, detector or inlet zones
 *       setpoint - value of setpoint from received command
 *       number - as ramp number
 */



static INT32 mGetOvenTempSetpt(void *parm, U_INT8 num);
static INT32 mGetOvenTempActual(void *parm, U_INT8 num);
static INT32 mGetFtInlTempSetpt(void *parm, U_INT8 num);
static INT32 mGetFtInlTempActual(void *parm, U_INT8 num);
static INT32 mGetBkInlTempSetpt(void *parm, U_INT8 num);
static INT32 mGetBkInlTempActual(void *parm, U_INT8 num);
static INT32 mGetFtInlTotalFlowSetpt(void *parm, U_INT8 num);
static INT32 mGetFtInlTotalFlowActual(void *parm, U_INT8 num);
static INT32 mGetBkInlTotalFlowSetpt(void *parm, U_INT8 num);
static INT32 mGetBkInlTotalFlowActual(void *parm, U_INT8 num);
static INT32 mGetFtInlPresSetpt(void *parm, U_INT8 num);
static INT32 mGetFtInlPresActual(void *parm, U_INT8 num);
static INT32 mGetBkInlPresSetpt(void *parm, U_INT8 num);
static INT32 mGetBkInlPresActual(void *parm, U_INT8 num);
static INT32 mGetFtDetTempSetpt(void *parm, U_INT8 num);
static INT32 mGetFtDetTempActual(void *parm, U_INT8 num);
static INT32 mGetBkDetTempSetpt(void *parm, U_INT8 num);
static INT32 mGetBkDetTempActual(void *parm, U_INT8 num);
static INT32 mGetFtDetFlowSetpt(void *parm, U_INT8 num);
static INT32 mGetFtDetFlowActual(void *parm, U_INT8 num);
static INT32 mGetBkDetFlowSetpt(void *parm, U_INT8 num);
static INT32 mGetBkDetFlowActual(void *parm, U_INT8 num);
static INT32 mGetC1FlowCalc(void *parm, U_INT8 num);
static INT32 mGetC2FlowCalc(void *parm, U_INT8 num);
static INT32 mGetAux1TempSetpt(void *parm, U_INT8 num);
static INT32 mGetAux1TempActual(void *parm, U_INT8 num);
static INT32 mGetAux2TempSetpt(void *parm, U_INT8 num);
static INT32 mGetAux2TempActual(void *parm, U_INT8 num);
static INT32 mGetAux3PresSetpt(void *parm, U_INT8 num);
static INT32 mGetAux3PresActual(void *parm, U_INT8 num);
static INT32 mGetAux4PresSetpt(void *parm, U_INT8 num);
static INT32 mGetAux4PresActual(void *parm, U_INT8 num);
static INT32 mGetAux5PresSetpt(void *parm, U_INT8 num);
static INT32 mGetAux5PresActual(void *parm, U_INT8 num);
static INT32 mGetSignalValue(void *parm, U_INT8 num);
static INT32 mGetSignalValue(void *parm, U_INT8 num);
static INT32  mGetValveActual(void *parm, U_INT8 num);
static INT32  mGetValveBcdInput(void *parm, U_INT8 num);

static INT32 mGetPresUnits(void *parm, U_INT8 num);
static INT32 mGetPostTimeSetpt(void *parm, U_INT8 num);
static INT32 mGetPostTempSetpt(void *zone, U_INT8 num);

/********/
/* GCST */
/********/

static INT32 mGetNotReady(void *parm, U_INT8 num);
static INT32 mGetNotReadyExt(void *parm, U_INT8 num);
static INT32 mGetWarning(void *parm, U_INT8 num);
static INT32 mGetShutdown(void *parm, U_INT8 num);
static INT32 mGetNonFatalErr(void *parm, U_INT8 num);

/********/
/* GCSV */
/********/

static INT32 mGetServiceCount(void *parm, U_INT8 num);
static UI_ERR mSetServiceCount(void *parm,INT32 setpt,U_INT8 num);

/********/
/* GCCF */
/********/

static INT32 mGetOvenType(void *parm, U_INT8 num);
static INT32 mGetZonePresence(void *parm, U_INT8 num);
static INT32 mGetCryoType(void *parm, U_INT8 num);
static INT32 mGetDetectorType(void *parm, U_INT8 num);
static INT32 mGetIsDetectorEpc(void *parm, U_INT8 num);
static INT32 mGetFDetPresSensor(void *parm, U_INT8 num);
static INT32 mGetBDetPresSensor(void *parm, U_INT8 num);
static INT32 mGetInletType(void *parm, U_INT8 num);
static INT32 mGetInletPresSensor(void *parm, U_INT8 num);
static INT32 mGetIsInletEpc(void *parm, U_INT8 num);
static INT32 mGetValveType(void *parm, U_INT8 num);
static INT32 mGetAuxType(void *parm, U_INT8 num);
static INT32 mGetAuxPresSensor(void *parm, U_INT8 num);
static INT32 mGetMioBdPresence(void *parm, U_INT8 num);
static INT32 mGetAlsPowerSupply(void *parm, U_INT8 num);
static INT32 mGetFrAlsInjector(void *parm, U_INT8 num);
static INT32 mGetBkAlsInjector(void *parm, U_INT8 num);
static INT32 mGetAlsTray(void *parm, U_INT8 num);
static INT32 mGetAlsHadPowerSupply(void *parm, U_INT8 num);
static INT32 mGetEpcBdPresence(void *parm, U_INT8 num);

/********/
/* GCTM */
/********/

static INT32 mGetFullClockTime(void *parm, U_INT8 num);
static INT32 mGetFullDate(void *parm, U_INT8 num);

static INT32 mGetRunState(void *parm, U_INT8 num);
static INT32 mGetBlankRunState(void *parm, U_INT8 num);
static INT32 mGetSccRunState(void *parm, U_INT8 num);
static INT32 mGetSequenceRunState(void *parm, U_INT8 num);
static INT32 mGetLastRunTime(void *parm, U_INT8 num);
static INT32 mGetRunLength(void *parm, U_INT8 num);
static INT32 mGetRunTime(void *parm, U_INT8 num);
static INT32 mGetRunTimeRemaining(void *parm, U_INT8 num);
static INT32 mGetPostTimeRemaining(void *parm, U_INT8 num);

static UI_ERR mSetPresUnits(void *parm,INT32 setpt,U_INT8 num);
static UI_ERR mSetPostTimeSetpt(void *parm,INT32 setpt,U_INT8 num);
static UI_ERR mSetPostTempSetpt(void *zone, INT32 setpt, U_INT8 ramp_number);

static UI_ERR mSetFullClockTime(void *parm,INT32 setpt,U_INT8 num);
static UI_ERR mSetDate(void *parm,INT32 setpt,U_INT8 num);

static UI_ERR DummyFunction(void *parm);


#if 0
static INT32  mGetColRampType      ( void *status, U_INT8 col_num )
{
      (void)status;

      if ( col_num == 1 )  return ( GetColumnRampType ( pCOLUMN_1 ) == FLOW_RAMP );
      if ( col_num == 2 )  return ( GetColumnRampType ( pCOLUMN_2 ) == FLOW_RAMP );

      return 0;
}
#endif



#if 0
static UI_ERR mTestColRampType     ( void *status, INT32 setpt, U_INT8 col_num )
{
      (void) status;

      if (( col_num == 1 ) &&  (( GetColumnRampType ( pCOLUMN_1 ) == FLOW_RAMP ) == setpt) ) return OK;
      if (( col_num == 2 ) &&  (( GetColumnRampType ( pCOLUMN_2 ) == FLOW_RAMP ) == setpt) ) return OK;

      return PARAM_ABORTED;
}
#endif



/********************* command table entries *********************/
/*
 * Format:
 *   static const METHCMD_ENTRY mmCommandTableEntries[] =
 *   {
 *     {mGetWrapperCommand, mSetWrapperCommand, number, type of setpoint}
 *   }
 */

static const METHCMD_ENTRY mmGCPO[] =
{
        {mGetPostTimeSetpt, mSetPostTimeSetpt, 0, METH_TIME},
        {mGetPostTempSetpt, mSetPostTempSetpt, 0, METH_TEMP}
};

static const METHCMD_ENTRY mmGCPU[] =
{
        {mGetPresUnits, mSetPresUnits, 0, METH_NUM},
};

static const METHCMD_ENTRY mmGCSA[] =
{
        {mGetOvenTempSetpt,        (SET)DummyFunction, 1, METH_INT2},
        {mGetOvenTempActual,       (SET)DummyFunction, 1, METH_INT2},
        {mGetFtInlTempSetpt,       (SET)DummyFunction, 1, METH_INT2},
        {mGetFtInlTempActual,      (SET)DummyFunction, 1, METH_INT2},
        {mGetFtInlPresSetpt,       (SET)DummyFunction, 1, METH_PRES},
        {mGetFtInlPresActual,      (SET)DummyFunction, 1, METH_PRES},
        {mGetFtInlTotalFlowSetpt,  (SET)DummyFunction, 1, METH_FLOW},
        {mGetFtInlTotalFlowActual, (SET)DummyFunction, 1, METH_FLOW},
        {mGetBkInlTempSetpt,       (SET)DummyFunction, 1, METH_INT2},
        {mGetBkInlTempActual,      (SET)DummyFunction, 1, METH_INT2},
        {mGetBkInlPresSetpt,       (SET)DummyFunction, 1, METH_PRES},
        {mGetBkInlPresActual,      (SET)DummyFunction, 1, METH_PRES},
        {mGetBkInlTotalFlowSetpt,  (SET)DummyFunction, 1, METH_FLOW},
        {mGetBkInlTotalFlowActual, (SET)DummyFunction, 1, METH_FLOW},
        {mGetFtDetTempSetpt,   (SET)DummyFunction, 1,        METH_INT2},
        {mGetFtDetTempActual,  (SET)DummyFunction, 1,        METH_INT2},
        {mGetFtDetFlowSetpt,   (SET)DummyFunction, FUEL_GAS, METH_FLOW},
        {mGetFtDetFlowActual,  (SET)DummyFunction, FUEL_GAS, METH_FLOW},
        {mGetFtDetFlowSetpt,   (SET)DummyFunction, UTIL_GAS, METH_FLOW},
        {mGetFtDetFlowActual,  (SET)DummyFunction, UTIL_GAS, METH_FLOW},
        {mGetFtDetFlowSetpt,   (SET)DummyFunction, MUG_GAS,  METH_FLOW},
        {mGetFtDetFlowActual,  (SET)DummyFunction, MUG_GAS,  METH_FLOW},
        {mGetBkDetTempSetpt,   (SET)DummyFunction, 1,        METH_INT2},
        {mGetBkDetTempActual,  (SET)DummyFunction, 1,        METH_INT2},
        {mGetBkDetFlowSetpt,   (SET)DummyFunction, FUEL_GAS, METH_FLOW},
        {mGetBkDetFlowActual,  (SET)DummyFunction, FUEL_GAS, METH_FLOW},
        {mGetBkDetFlowSetpt,   (SET)DummyFunction, UTIL_GAS, METH_FLOW},
        {mGetBkDetFlowActual,  (SET)DummyFunction, UTIL_GAS, METH_FLOW},
        {mGetBkDetFlowSetpt,   (SET)DummyFunction, MUG_GAS,  METH_FLOW},
        {mGetBkDetFlowActual,  (SET)DummyFunction, MUG_GAS,  METH_FLOW},
        {mGetC1FlowCalc,       (SET)DummyFunction, 1,        METH_FLOW},
        {mGetC2FlowCalc,       (SET)DummyFunction, 1,        METH_FLOW},
        {mGetAux1TempSetpt,        (SET)DummyFunction, 1, METH_INT2},
        {mGetAux1TempActual,       (SET)DummyFunction, 1, METH_INT2},
        {mGetAux2TempSetpt,        (SET)DummyFunction, 1, METH_INT2},
        {mGetAux2TempActual,       (SET)DummyFunction, 1, METH_INT2},
        {mGetAux3PresSetpt,        (SET)DummyFunction, 1, METH_PRES},
        {mGetAux3PresActual,       (SET)DummyFunction, 1, METH_PRES},
        {mGetAux4PresSetpt,        (SET)DummyFunction, 1, METH_PRES},
        {mGetAux4PresActual,       (SET)DummyFunction, 1, METH_PRES},
        {mGetAux5PresSetpt,        (SET)DummyFunction, 1, METH_PRES},
        {mGetAux5PresActual,       (SET)DummyFunction, 1, METH_PRES},
        {mGetSignalValue,          (SET)DummyFunction, 1, METH_INT0},
        {mGetSignalValue,          (SET)DummyFunction, 2, METH_INT0},
        {mGetValveActual,          (SET)DummyFunction, 1, METH_INT0},
        {mGetValveActual,          (SET)DummyFunction, 2, METH_INT0},
        {mGetValveActual,          (SET)DummyFunction, 3, METH_INT0},
        {mGetValveActual,          (SET)DummyFunction, 4, METH_INT0},
        {mGetValveActual,          (SET)DummyFunction, 5, METH_INT0},
        {mGetValveActual,          (SET)DummyFunction, 6, METH_INT0},
        {mGetValveActual,          (SET)DummyFunction, 7, METH_INT0},
        {mGetValveActual,          (SET)DummyFunction, 8, METH_INT0},
        {mGetValveBcdInput,        (SET)DummyFunction, 0, METH_INT0},
        {mGetRunTime,              (SET)DummyFunction, 0, METH_INT2}
};


static const METHCMD_ENTRY mmGCST[] =
{
        {mGetNotReady,    (SET)DummyFunction, 1, METH_HEX},
        {mGetNotReady,    (SET)DummyFunction, 2, METH_HEX},
        {mGetNotReady,    (SET)DummyFunction, 3, METH_HEX},
        {mGetNotReadyExt, (SET)DummyFunction, 0, METH_HEX},
        {mGetWarning,     (SET)DummyFunction, 1, METH_HEX},
        {mGetWarning,     (SET)DummyFunction, 2, METH_HEX},
        {mGetWarning,     (SET)DummyFunction, 3, METH_HEX},
        {mGetWarning,     (SET)DummyFunction, 4, METH_HEX},
        {mGetShutdown,    (SET)DummyFunction, 1, METH_HEX},
        {mGetShutdown,    (SET)DummyFunction, 2, METH_HEX},
        {mGetNonFatalErr, (SET)DummyFunction, 1, METH_HEX},
        {mGetNonFatalErr, (SET)DummyFunction, 2, METH_HEX},
        {mGetNonFatalErr, (SET)DummyFunction, 3, METH_HEX},
        {mGetNonFatalErr, (SET)DummyFunction, 4, METH_HEX},
        {mGetNonFatalErr, (SET)DummyFunction, 5, METH_HEX},
};

static const METHCMD_ENTRY mmGCSV[] =
{
        {mGetServiceCount,   mSetServiceCount,    0, METH_INT0},
        {mGetServiceCount,   mSetServiceCount,    1, METH_INT0},
        {mGetServiceCount,   mSetServiceCount,    2, METH_INT0},
        {mGetServiceCount,   mSetServiceCount,    3, METH_INT0},
        {mGetServiceCount,   mSetServiceCount,    4, METH_INT0},
        {mGetServiceCount,   mSetServiceCount,    5, METH_INT0},
        {mGetServiceCount,   mSetServiceCount,    6, METH_INT0},
        {mGetServiceCount,   mSetServiceCount,    7, METH_INT0},
};

static const METHCMD_ENTRY mmGCCF[] =
{
        {mGetOvenType,      NULL, 0,                  METH_INT0},
        {mGetZonePresence,  NULL, (U_INT8)OVEN_ZONE,  METH_INT0},
        {mGetCryoType,      NULL, 0,                  METH_INT0},

        {mGetDetectorType,   NULL, (U_INT8)FRONT,     METH_INT0},
        {mGetZonePresence,   NULL, (U_INT8)DETA_ZONE, METH_INT0},
        {mGetIsDetectorEpc,  NULL, (U_INT8)FRONT,     METH_INT0},
        {mGetFDetPresSensor, NULL, 1,                 METH_INT0},
        {mGetFDetPresSensor, NULL, 2,                 METH_INT0},
        {mGetFDetPresSensor, NULL, 3,                 METH_INT0},

        {mGetDetectorType,   NULL, (U_INT8)BACK,      METH_INT0},
        {mGetZonePresence,   NULL, (U_INT8)DETB_ZONE, METH_INT0},
        {mGetIsDetectorEpc,  NULL, (U_INT8)BACK,      METH_INT0},
        {mGetBDetPresSensor, NULL, 1,                 METH_INT0},
        {mGetBDetPresSensor, NULL, 2,                 METH_INT0},
        {mGetBDetPresSensor, NULL, 3,                 METH_INT0},

        {mGetInletType,       NULL, (U_INT8)FRONT,    METH_INT0},
        {mGetZonePresence,    NULL, (U_INT8)INJA_ZONE, METH_INT0},
        {mGetIsInletEpc,      NULL, (U_INT8)FRONT,    METH_INT0},
        {mGetInletPresSensor, NULL, (U_INT8)FRONT,    METH_INT0},

        {mGetInletType,       NULL, (U_INT8)BACK,     METH_INT0},
        {mGetZonePresence,    NULL, (U_INT8)INJB_ZONE, METH_INT0},
        {mGetIsInletEpc,      NULL, (U_INT8)BACK,     METH_INT0},
        {mGetInletPresSensor, NULL, (U_INT8)BACK,     METH_INT0},

        {mGetAuxType,       NULL, 1,                  METH_INT0},
        {mGetZonePresence,  NULL, (U_INT8)AUXA_ZONE,  METH_INT0},
        {mGetAuxType,       NULL, 2,                  METH_INT0},
        {mGetZonePresence,  NULL, (U_INT8)AUXB_ZONE,  METH_INT0},
        {mGetAuxType,       NULL, 3,                  METH_INT0},
        {mGetAuxPresSensor, NULL, 3,                  METH_INT0},
        {mGetAuxType,       NULL, 4,                  METH_INT0},
        {mGetAuxPresSensor, NULL, 3,                  METH_INT0},
        {mGetAuxType,       NULL, 5,                  METH_INT0},
        {mGetAuxPresSensor, NULL, 5,                  METH_INT0},
        {mGetValveType,     NULL, 1,                  METH_INT0},
        {mGetValveType,     NULL, 2,                  METH_INT0},
        {mGetValveType,     NULL, 3,                  METH_INT0},
        {mGetValveType,     NULL, 4,                  METH_INT0},
        {mGetValveType,     NULL, 5,                  METH_INT0},
        {mGetValveType,     NULL, 6,                  METH_INT0},
        {mGetValveType,     NULL, 7,                  METH_INT0},
        {mGetValveType,     NULL, 8,                  METH_INT0},

        {mGetMioBdPresence, NULL, 0,                  METH_INT0},

        {mGetAlsPowerSupply,    NULL, 0,              METH_INT0},
        {mGetFrAlsInjector,     NULL, 0,              METH_INT0},
        {mGetBkAlsInjector,     NULL, 0,              METH_INT0},
        {mGetAlsTray,           NULL, 0,              METH_INT0},
        {mGetAlsHadPowerSupply, NULL, 0,              METH_INT0},

        {mGetEpcBdPresence, NULL, 0,                  METH_INT0},
};

static const METHCMD_ENTRY mmGCTM[] =
{
        {mGetFullClockTime, mSetFullClockTime, 0, METH_FILL6},

        {mGetFullDate, mSetDate, 0, METH_FILL6},
};

static const METHCMD_ENTRY mmGCRI[] =
{
        {mGetRunState,          (SET)DummyFunction, 0, METH_INT0},
        {mGetBlankRunState,     (SET)DummyFunction, 0, METH_INT0},
        {mGetSccRunState,       (SET)DummyFunction, 0, METH_INT0},
        {mGetSequenceRunState,  (SET)DummyFunction, 0, METH_INT0},
        {mGetRunTimeRemaining,  (SET)DummyFunction, 0, METH_INT2},
        {mGetPostTimeRemaining, (SET)DummyFunction, 0, METH_INT2},
        {mGetRunTime,           (SET)DummyFunction, 0, METH_INT2},
        {mGetLastRunTime,       (SET)DummyFunction, 0, METH_INT2},
        {mGetRunLength,         (SET)DummyFunction, 0, METH_INT2},
};

/********************* command tables *********************/
/*
 * Need on for each command.  If there are multible locations
 *    such as front/back or V1/V2/V3...V8 need one command table
 *    for each.  "paramter" is used to indicate which location.
 * Format:
 *   const METHCMD mCommandTable[] =
 *   {
 *      MAXINDEX(mmCommandTableEntries, METHCMD_ENTRY),
 *      &mmCommandTableEntries[starting_index_in_table],
 *      parameter,    --- need a pointer to a const = (void * const)
 *      PreCommandFunction,
 *      PostCommandFunction
 *   }
 */

const METHCMD mGCPO =
{
        MAXINDEX(mmGCPO, METHCMD_ENTRY),
        &mmGCPO[0],
        pOVEN_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mGCPU =
{
        MAXINDEX(mmGCPU, METHCMD_ENTRY),
        &mmGCPU[0],
        (void *)NULL,
        DummyFunction,
        DummyFunction
};

const METHCMD mGCSA =
{
        MAXINDEX(mmGCSA, METHCMD_ENTRY),
        &mmGCSA[0],
        (void *)NULL,
        DummyFunction,
        DummyFunction
};

const METHCMD mGCST =
{
        MAXINDEX(mmGCST, METHCMD_ENTRY),
        &mmGCST[0],
        (void *)NULL,
        DummyFunction,
        DummyFunction
};

const METHCMD mGCSV =
{
        MAXINDEX(mmGCSV, METHCMD_ENTRY),
        &mmGCSV[0],
        (void *)NULL,
        DummyFunction,
        DummyFunction
};

const METHCMD mGCCF =
{
        MAXINDEX(mmGCCF, METHCMD_ENTRY),
        &mmGCCF[0],
        (void *)NULL,
        DummyFunction,
        DummyFunction
};

const METHCMD mGCTM =
{
        MAXINDEX(mmGCTM, METHCMD_ENTRY),
        &mmGCTM[0],
        (void *)NULL,
        DummyFunction,
        DummyFunction
};

const METHCMD mGCRI =
{
        MAXINDEX(mmGCRI, METHCMD_ENTRY),
        &mmGCRI[0],
        (void *)NULL,
        DummyFunction,
        DummyFunction
};


/********************* "get" wrapper functions *********************/

static UI_ERR DummyFunction(void *parm)
{
      (void) parm;
      return OK;
}


static INT32 mGetOvenTempSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempSetptScaled ( pOVEN_TEMP, 2 );

}

static INT32 mGetOvenTempActual(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempActualScaled ( pOVEN_TEMP, 2 );
}

static INT32 mGetFtInlTempSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempSetptScaled ( pFRONT_INLET_TEMP, 2 );

}

static INT32 mGetFtInlTempActual(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempActualScaled ( pFRONT_INLET_TEMP, 2 );
}

static INT32 mGetBkInlTempSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempSetptScaled ( pBACK_INLET_TEMP, 2 );

}

static INT32 mGetBkInlTempActual(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempActualScaled ( pBACK_INLET_TEMP, 2 );
}

static INT32 mGetFtInlTotalFlowSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return DcGetInletFlowSetpt (pFRONT_INLET);

}

static INT32 mGetFtInlTotalFlowActual(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return DcGetInletFlowActual (pFRONT_INLET);
}

static INT32 mGetBkInlTotalFlowSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return DcGetInletFlowSetpt (pBACK_INLET);

}

static INT32 mGetBkInlTotalFlowActual(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return DcGetInletFlowActual (pBACK_INLET);
}

static INT32 mGetFtInlPresSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return DcGetInletPresSetpt (pFRONT_INLET);

}

static INT32 mGetFtInlPresActual(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return DcGetInletPresActual (pFRONT_INLET);
}

static INT32 mGetBkInlPresSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return DcGetInletPresSetpt (pBACK_INLET);

}

static INT32 mGetBkInlPresActual(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return DcGetInletPresActual (pBACK_INLET);
}


static INT32 mGetFtDetTempSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempSetptScaled ( pFRONT_DET_TEMP, 2 );
}

static INT32 mGetFtDetTempActual(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempActualScaled ( pFRONT_DET_TEMP, 2 );
}

static INT32 mGetBkDetTempSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempSetptScaled ( pBACK_DET_TEMP, 2 );
}

static INT32 mGetBkDetTempActual(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempActualScaled ( pBACK_DET_TEMP, 2 );
}

static INT32 mGetFtDetFlowSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        return DcGetDetectorGasFlowSetpt ( pFRONT_DETECTOR,num );

}

static INT32 mGetFtDetFlowActual(void *parm, U_INT8 num)
{
   (void) parm;
   return DcGetDetectorGasFlowActual ( pFRONT_DETECTOR, num );
}

static INT32 mGetBkDetFlowSetpt(void *parm, U_INT8 num)
{
   (void) parm;
   return DcGetDetectorGasFlowSetpt ( pBACK_DETECTOR, num );
}

static INT32 mGetBkDetFlowActual(void *parm, U_INT8 num)
{
   (void) parm;
   return DcGetDetectorGasFlowActual ( pBACK_DETECTOR, num );
}

static INT32 mGetC1FlowCalc(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;

   return  DcGetColumnActualFlow( pCOLUMN_1 );
}

static INT32 mGetC2FlowCalc(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;

   return DcGetColumnActualFlow( pCOLUMN_2 );
}

static INT32 mGetAux1TempSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempSetptScaled ( pAUX_1_TEMP, 2 );
}

static INT32 mGetAux1TempActual(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempActualScaled ( pAUX_1_TEMP, 2 );
}


static INT32 mGetAux2TempSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempSetptScaled ( pAUX_2_TEMP, 2 );
}

static INT32 mGetAux2TempActual(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetTempActualScaled ( pAUX_2_TEMP, 2 );
}

static INT32 mGetAux3PresSetpt(void *parm, U_INT8 num)
{
   (void) num;
   (void) parm;
   return DcGetAuxPresSetpt ( pAUX_3 );
}
static INT32 mGetAux3PresActual(void *parm, U_INT8 num)
{
   (void) num;
   (void) parm;
   return DcGetAuxPresActual ( pAUX_3 );
}
static INT32 mGetAux4PresSetpt(void *parm, U_INT8 num)
{
   (void) num;
   (void) parm;
   return DcGetAuxPresSetpt ( pAUX_4 );
}
static INT32 mGetAux4PresActual(void *parm, U_INT8 num)
{
   (void) num;
   (void) parm;
   return DcGetAuxPresActual ( pAUX_4 );
}
static INT32 mGetAux5PresSetpt(void *parm, U_INT8 num)
{
   (void) num;
   (void) parm;
   return DcGetAuxPresSetpt ( pAUX_5 );
}
static INT32 mGetAux5PresActual(void *parm, U_INT8 num)
{
   (void) num;
   (void) parm;
   return DcGetAuxPresActual ( pAUX_5 );
}

static INT32 mGetSignalValue(void *parm, U_INT8 num)
{
   (void) parm;

   if( num == 1)
   {
      return  Signal1.last_reading;
   }
   else
   {
      return  Signal2.last_reading;
   }
}

static INT32  mGetValveActual(void *parm, U_INT8 num)
{
        (void) parm;
        if( GetValveState(num) == ON )
        {
           return 1;
        }
        else
        {
           return 0;
        }
}

static INT32  mGetValveBcdInput(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;
   return (INT32) GetValveBcdInput();
}



static INT32 mGetPresUnits(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return (INT32) GetPresUnits();
}

static INT32 mGetPostTimeSetpt(void *parm, U_INT8 num)
{
        (void) parm;
        (void) num;
        return GetPostTimeSetpt();
}

static INT32 mGetPostTempSetpt(void *zone, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return GetPostTempSetpt();
}



/********/
/* GCST */
/********/

static INT32  mGetNotReady(void *parm, U_INT8 num)
{
      (void) parm;
      return GetNotReady(num);
}


static INT32   mGetNotReadyExt(void *parm, U_INT8 num)
{
      (void) num;
      (void) parm;
      return GetNotReadyExt();
}


static INT32   mGetWarning(void *parm, U_INT8 num)
{
      (void) parm;
      return GetWarning(num);
}


static INT32   mGetShutdown(void *parm, U_INT8 num)
{
      (void) parm;
      return GetShutdown(num);
}


static INT32   mGetNonFatalErr(void *parm, U_INT8 num)
{
      (void) parm;
      return GetNonFatalErr(num);
}


/********/
/* GCSV */
/********/

static INT32 mGetServiceCount(void *parm, U_INT8 num)
{
   (void) parm;
   return Service_Count[num];
}


/********/
/* GCCF */
/********/

static INT32 mGetOvenType(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;
   return GetZoneType( pOVEN_TEMP );
}

static INT32 mGetZonePresence(void *parm, U_INT8 num)
{
   pZONE_TABLE pzone;

   (void) parm;

   pzone = GetZonePtr((ZONE_TYPE)num);

   switch ( num )
   {
      case INJA_ZONE:
      case INJB_ZONE:
      case AUXA_ZONE:
      case AUXB_ZONE: return (INT32)GetZonePresence(pzone);
      default:        return (INT32)GetTempZonePresence(pzone);
   }
}

static INT32 mGetCryoType(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;
   return (INT32)GetCryoType(pOVEN_TEMP );
}

static INT32 mGetDetectorType(void *parm, U_INT8 num)
{
   (void) parm;

   return (INT32)GetDetectorType( (POSITION)num );
}

static INT32 mGetIsDetectorEpc(void *parm, U_INT8 num)
{
   (void ) parm;

   return (INT32)IsDetectorEpc( (POSITION)num );
}

static INT32 mGetDetPresSensor( pDETECTOR_STATUS status, U_INT8 num)
{
    return GetDetPSensorRange( status, num );
}

static INT32 mGetFDetPresSensor(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;

   return mGetDetPresSensor(pFRONT_DETECTOR, num);
}

static INT32 mGetBDetPresSensor(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;

   return mGetDetPresSensor(pBACK_DETECTOR, num);
}

static INT32 mGetInletType(void *parm, U_INT8 num)
{
   (void) parm;

   if ( num == (U_INT8)FRONT )
   {
      return (INT32)GetInletType( pFRONT_INLET );
   }
   else
   {
      return (INT32)GetInletType( pBACK_INLET );
   }
}

static INT32 mGetIsInletEpc(void *parm, U_INT8 num)
{
   pINLET_STATUS pstatus;

   (void ) parm;

   if ( num == (U_INT8)FRONT )
   {
      pstatus = pFRONT_INLET;
   }
   else
   {
      pstatus = pBACK_INLET;
   }

   return EpcInletChk(pstatus) ;
}


static INT32 mGetInletPresSensor(void *parm, U_INT8 num)
{
   (void) parm;

   if ( num == (U_INT8)FRONT )
   {
      return GetInletPSensorRange( pFRONT_INLET );
   }
   else
   {
      return GetInletPSensorRange( pBACK_INLET );
   }
}

static INT32 mGetAuxType(void *parm, U_INT8 num)
{
   (void) parm;

   switch( num )
   {
      case 1:  return GetZoneType( pAUX_1_TEMP );
      case 2:  return GetZoneType( pAUX_2_TEMP );
      case 3:
      case 4:
      default:
/* REVISIT:  would be nice to get this broken down to each aux 3-5 */
      case 5:  return( PneuAuxPresent() ? 1 : 0 );
   }
}

static INT32 mGetAuxPresSensor(void *parm, U_INT8 num)
{
   (void) parm;

   switch ( num )
   {
      case 3:  return GetAuxPSensorRange( pAUX_3 );
      case 4:  return GetAuxPSensorRange( pAUX_4 );
      default:
      case 5:  return GetAuxPSensorRange( pAUX_5 );
   }
}

static INT32 mGetValveType(void *parm, U_INT8 num)
{
   (void) parm;
   return (INT32)GetValveType( num );
}

static INT32 mGetMioBdPresence(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;
   if ((LAN_serial_number[0] != 0) &&
       (LAN_MAC_address[0] != 0) &&
       (LAN_software_version[0] != 0))
   {
      return TRUE;
   }
   else
   {
      return FALSE;
   }
}

static INT32 mGetAlsPowerSupply(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;
   return (INT32)HaveAlsPowerSupply();
}

static INT32 mGetFrAlsInjector(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;
   return (INT32)AnyFrAlsInjector();
}

static INT32 mGetBkAlsInjector(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;
   return (INT32)AnyBkAlsInjector();
}

static INT32 mGetAlsTray(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;
   return (INT32)AnyAlsTray();
}

static INT32 mGetAlsHadPowerSupply(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;
   return (INT32)TRUE;
}

static INT32 mGetEpcBdPresence(void *parm, U_INT8 num)
{
   (void) parm;
   (void) num;
   if ( IamAdirtball() ) return FALSE;
   return TRUE;
}

/********/
/* GCTM */
/********/

static INT32   mGetFullClockTime(void *parm, U_INT8 num)
{
      (void) parm;
      (void) num;
      return GetFullClockTime();
}

static INT32   mGetFullDate(void *parm, U_INT8 num)
{
      (void) parm;
      (void) num;
      return GetFullDate();
}

static INT32   mGetRunState(void *parm, U_INT8 num)
{
      (void) parm;
      (void) num;
      return (INT32)Run_State;
}
static INT32   mGetBlankRunState(void *parm, U_INT8 num)
{
      (void) parm;
      (void) num;
      return (Blank_Run == FALSE) ? 0 : 1;
}
static INT32   mGetSccRunState(void *parm, U_INT8 num)
{
      (void) parm;
      (void) num;
      return (Scc_Run == FALSE) ? 0 : 1;
}
static INT32   mGetSequenceRunState(void *parm, U_INT8 num)
{
      (void) parm;
      (void) num;
      return (SequenceInProgress() == FALSE) ? 0 : 1;
}

static INT32   mGetLastRunTime(void *parm, U_INT8 num)
{
      (void) parm;
      (void) num;
      return (INT32)GetLastRunTime();
}

static INT32   mGetRunLength(void *parm, U_INT8 num)
{
      (void) parm;
      (void) num;
      return (INT32)GetRunLength();
}

static INT32   mGetRunTime(void *parm, U_INT8 num)
{
      (void) parm;
      (void) num;
      return (INT32)GetRunTime();
}

static INT32   mGetRunTimeRemaining(void *parm, U_INT8 num)
{
      (void) parm;
      (void) num;
      if(RunInProgress() == TRUE)
      {
         return ( (INT32)GetRunLength() - (INT32)GetRunTime() );
      }
      else
      {
         return (INT32)GetRunLength();
      }
}

static INT32   mGetPostTimeRemaining(void *parm, U_INT8 num)
{
      (void) parm;
      (void) num;
      return (INT32)PostTimeRemaining();
}


/********************* "set" wrapper functions *********************/

static UI_ERR mSetPresUnits(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return SetPresUnits((PRES_UNITS) setpt);
}

static UI_ERR mSetPostTempSetpt(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return SetPostTempSetpt(setpt);
}

static UI_ERR mSetPostTimeSetpt(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return DcSetPostTimeSetpt(setpt);
}



static UI_ERR  mSetFullClockTime(void *parm,INT32 setpt,U_INT8 num)
{
      /* REVISIT: add this function later */
      (void) parm;
      (void) num;
      return SetFullClockTime(setpt);
}

static UI_ERR  mSetDate(void *parm,INT32 setpt,U_INT8 num)
{
      /* REVISIT: add this function later */
      (void) parm;
      (void) num;
      return SetDate(setpt);
}


/********/
/* GCSV */
/********/

static UI_ERR mSetServiceCount(void *parm, INT32 setpt, U_INT8 num)
{
   (void) parm;
   if (setpt < 0) return PARAM_TOO_SMALL;
   if (setpt > 65535) return PARAM_TOO_LARGE;

   Service_Count[num] = setpt;
   return OK;
}



/******************* "pre" and "post" functions ********************/
